<template>
  <view>
    <button @click="upload" class="but">户主身份证识别</button>
    <div class="card_info">
        <view class="li">姓名：{{caidData.NAME || ''}}</view>
        <view class="li">性别：{{caidData.SEX || ''}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;民族：{{caidData.MZ || ''}}</view>
        <view class="li">出生：{{caidData.BIRTHDAY || ''}}</view>
        <view class="li">住址：{{caidData.ADDRESS || ''}}</view>
        <view class="li">身份证号码：{{caidData.ID || ''}}</view>
    </div>
    <!-- <button @click="goEditallowances" class="but">户主人脸验证</button> -->
  </view>
</template>

<script>
  export default {
    data() {
      return {
        caidData: {}
      }
    },
    onLoad() {
    },
    methods: {
      goEditallowances () {
        let that = this
        this.$http.get('checkedit', {params: {ID: this.caidData.ID, NAME: this.caidData.NAME,
        }}).then(res => {
            if (res.data.code == 0) {
                uni.navigateTo({
                  url: './allowancesFill?data=' + encodeURIComponent(JSON.stringify(res.data.LowInfor)) + '&edit=' + true
                })
            } else {
                uni.showModal({
                  title: '提示',
                  showCancel: false,
                  content: res.data.message
                });
            }
        })
      },
      // 识别身份证
      upload() {
          let that = this
          uni.chooseImage({
              count: 1,
              sizeType: ['compressed'],
              sourceType: ['camera'],
              success: function (self) {
                  uni.showLoading()
                  that.$http.upload('Getidcard', {filePath: self.tempFilePaths[0], name: encodeURI('filePath'),
                  }).then(res => {
                      if (JSON.parse(res).error_code === 0) {
                          that.caidData = JSON.parse(res).data.IDCARD
                          that.goEditallowances()
                      } else {
                          uni.showToast({
                              title: '识别失败',
                              duration: 2000,
                              icon: 'none'
                          });
                      }
                      uni.hideLoading()
                  })
              }
          })
      },
      globalGetData() {
      }
    }
  }
</script>

<style lang="scss" scoped>
.but{
    background-color: #1EC88B;
    border: none;
    height: 94upx;
    line-height: 94upx;
    text-align: center;
    border-radius: 10upx;
    color: #fff;
    margin: 20upx;
    font-size: 36upx;
}
.card_info{
    border-top: 1px solid #bbb;
    border-bottom: 1px solid #bbb;
    font-size: 28upx;
    color: #101010;
    padding: 28upx;
    position: relative;
    .li{
        line-height: 60upx;
    }
    .user_pic{
        position: absolute;
        right: 28upx;
        top: 28upx;
        width: 170upx;
        height: 160upx;
    }
}
</style>
